Skip to content

feat: Implemented Tagged Strings support#1

Open
crossi704 wants to merge 2 commits intodignifiedquire:tagsfrom
crossi704:tags
Open

feat: Implemented Tagged Strings support#1
crossi704 wants to merge 2 commits intodignifiedquire:tagsfrom
crossi704:tags

Conversation

@crossi704
Copy link

@crossi704 crossi704 commented Sep 18, 2019

A contribution to String tag support in Serdes.
Rust lacks specialization support yet, therefore type implementation must be done from within the library.

According to Concise Binary Object Representation (CBOR)
CBOR URI (CBOR type 32) must be represented as a UTF-8 String with tag 32.
The changes done in this pull request allows one to successfully represent it by using the following code:

Example:

let cbor_uri_encoded = serde_cbor::TaggedString{tag: 32, data: "example".to_string()};
let encoded = serde_cbor::to_vec(&cbor_uri_encoded);

CBOR playground
32("example")

D8 20 # tag(32)
67 # text(7)
6578616D706C65 # "example"

@crossi704 crossi704 marked this pull request as ready for review September 18, 2019 14:54
Copy link
Owner

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, happy to include this, could you please add a test for it, and some doc comments with an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants